#pragma once

#include "Holders.h"
#include "Exceptions.h"

class WMReaderModel : public QObject
{
    Q_OBJECT
public:
    WMReaderModel();
    ~WMReaderModel();
public slots:
    void ConnectToDevice();
    void DisconnectFromDevice();

    void RetrieveFileSystem(QTreeWidgetItem *topItem);
    void RetrieveRegistryKeysList(QTreeWidgetItem *topItem);
    void RetrieveRegistryKeyValues(QTreeWidgetItem *topItem);
    void RetrieveDeviceInfo();
signals:
    void DeviceConnected();
    void DeviceDisconnected();
    
    void FileSystemRetrieved(QTreeWidgetItem *topItem, std::vector <CE_FIND_DATA> *fileSystemItems);
    void RegistryKeysListRetrieved(QTreeWidgetItem *topItem, std::vector <registry_set::REGKEY> *registryKeys);
    void RegistryKeyValuesRetrieved(std::vector <registry_set::REGKEYVALUE> *keyValues);
    void DeviceInfoRetrieved(std::vector <device_info::DEVICEINFO> *deviceInfo);
    
    void RequestShowErrorMessage(const QString &message);
private:
    bool m_RapiInited;
    
    template <typename reciveType>
    void RetrieveDataFromDevice(const std::wstring &input,
                                const std::wstring &funcName,
                                std::vector <reciveType> &reciveItems);

    void GetAppMgrPath(std::wstring &appMgrPath);
    void CheckConnection();
    void InstallLibToDevice();
    bool IsLibInstalled();
};